<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            border: 1px solid black;
            margin: 10px;
        }

        /* 匹配第一个元素 */
        /* div:first-child{
            background-color: red;
        }   */
        
        /* div:last-child{
            background-color: red;
        }  */

        /* 匹配第n个 n从1开始*/
        /* 2n代表偶数   2n+1代表奇数*/
        /* div:nth-child(10){
            background-color: red;
        } */

        /* 匹配第n个 */
        /* div:nth-of-type(4){
            background-color: red;
        } */

        /* 前面3个 */
        /* div:nth-of-type(-n+3){
            background-color: red;
        } */

        /* 伪类选择器 */
        div:hover{
            background-color: red;
        }
        /* 后面3个 */
        /* div:nth-of-type(n+3){
            background-color: red;
        } */
        /* nth-child  是将所有孩子都排序  然后选择匹配的标签 
        nth-of-type   先将标签选出来   再进行排序*/
    </style>
</head>
<body>
    
    <!-- <p></p>
    <p></p>
    <p></p>
    <p></p>
    <p></p> -->
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</body>
</html>